package enumAndAnnotation;

/**
 * 枚举练习
 */
public class EnumExercise08 {

    public static void main(String[] args) {

        /*
            有一个 Car类 有属性 temperature(温度)，车内有Air(空调)类，有吹风的功能flow，
            Air会监视车内的温度，如果温度超过40°则吹冷气。如果温度低于0°则吹暖气，如果在这之间则关掉空调。
            实例化具有不同温度的Car对象，调用空调的flow 方法，测试空调吹的风是否正确(成员内部类)
         */
        Cars c1 = new Cars(42.0);
        Cars.Air air = c1.new Air();
        air.flow();

        Cars c2 = new Cars(37.0);
        Cars.Air airInstance = c2.getAirInstance();
        airInstance.flow();
    }
}

class Cars {

    private double temperature;

    public Cars(double temperature) {
        this.temperature = temperature;
    }

    public class Air{

        public void flow() {
            if (temperature > 40.0) {
                System.out.println("吹冷气...");
            } else if (temperature < 0.0) {
                System.out.println("吹暖气...");
            } else {
                System.out.println("关掉空调...");
            }
        }
    }

    public Air getAirInstance() {
        return new Air();
    }

    public double getTemperature() {
        return temperature;
    }

    public void setTemperature(double temperature) {
        this.temperature = temperature;
    }
}